home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / audiol1a / module1.bas < prev    next >
BASIC Source File  |  1998-04-14  |  54KB  |  830 lines

  1. Attribute VB_Name = "Module1"
  2. Option Explicit
  3.  
  4. Public Const CALLBACK_FUNCTION = &H30000
  5. Public Const MM_WIM_DATA = &H3C0
  6. Public Const WHDR_DONE = &H1         '  done bit
  7. Public Const GMEM_FIXED = &H0         ' Global Memory Flag used by GlobalAlloc functin
  8.  
  9. Type WAVEHDR
  10. ' The WAVEHDR user-defined type defines the header used to identify a waveform-audio buffer.
  11.    lpData As Long          ' Address of the waveform buffer.
  12.    dwBufferLength As Long  ' Length, in bytes, of the buffer.
  13.    dwBytesRecorded As Long ' When the header is used in input, this member specifies how much
  14.                            ' data is in the buffer.
  15.  
  16.    dwUser As Long          ' User data.
  17.    dwFlags As Long         ' Flags supplying information about the buffer. Set equal to zero.
  18.    dwLoops As Long         ' Number of times to play the loop. Set equal to zero.
  19.    lpNext As Long          ' Not used
  20.    Reserved As Long        ' Not used
  21. End Type
  22.  
  23. Type WAVEINCAPS
  24. ' The WAVEINCAPS user-defined variable describes the capabilities of a waveform-audio input
  25. ' device.
  26.    wMid As Integer         ' Manufacturer identifier for the device driver for the
  27.                            ' waveform-audio input device. Manufacturer identifiers
  28.                            ' are defined in Manufacturer and Product Identifiers in
  29.                            ' the Platform SDK product documentation.
  30.    wPid As Integer         ' Product identifier for the waveform-audio input device.
  31.                            ' Product identifiers are defined in Manufacturer and Product
  32.                            ' Identifiers in the Platform SDK product documentation.
  33.    vDriverVersion As Long  ' Version number of the device driver for the
  34.                            ' waveform-audio input device. The high-order byte
  35.                            ' is the major version number, and the low-order byte
  36.                            ' is the minor version number.
  37.    szPname As String * 32  ' Product name in a null-terminated string.
  38.    dwFormats As Long       ' Standard formats that are supported. See the Platform
  39.                            ' SDK product documentation for more information.
  40.    wChannels As Integer    ' Number specifying whether the device supports
  41.                            ' mono (1) or stereo (2) input.
  42. End Type
  43.  
  44. Type WAVEFORMAT
  45. ' The WAVEFORMAT user-defined type describes the format of waveform-audio data. Only
  46. ' format information common to all waveform-audio data formats is included in this
  47. ' user-defined type.
  48.    wFormatTag As Integer      ' Format type. Use the constant WAVE_FORMAT_PCM Waveform-audio data
  49.                               ' to define the data as PCM.
  50.    nChannels As Integer       ' Number of channels in the waveform-audio data. Mono data uses one
  51.                               ' channel and stereo data uses two channels.
  52.    nSamplesPerSec As Long     ' Sample rate, in samples per second.
  53.    nAvgBytesPerSec As Long    ' Required average data transfer rate, in bytes per second. For
  54.                               ' example, 16-bit stereo at 44.1 kHz has an average data rate of
  55.                               ' 176,400 bytes per second (2 channels ù 2 bytes per sample per
  56.                               ' channel ù 44,100 samples per second).
  57.    nBlockAlign As Integer     ' Block alignment, in bytes. The block alignment is the minimum atomic unit of data. For PCM data, the block alignment is the number of bytes used by a single sample, including data for both channels if the data is stereo. For example, the block alignment for 16-bit stereo PCM is 4 bytes (2 channels ù 2 bytes per sample).
  58.    wBitsPerSample As Integer  ' For buffer estimation
  59.    cbSize As Integer          ' Block size of the data.
  60. End Type
  61.  
  62. Declare Function waveInOpen Lib "winmm.dll" (lphWaveIn As Long, _
  63.                                              ByVal uDeviceID As Long, _
  64.                                              lpFormat As WAVEFORMAT, _
  65.                                              ByVal dwCallback As Long, _
  66.                                              ByVal dwInstance As Long, _
  67.                                              ByVal dwFlags As Long) As Long
  68. ' The waveInOpen function opens the given waveform-audio input device for recording. The function
  69. ' uses the following parameters
  70. '     lphWaveIn-  a long value that is the handle identifying the open waveform-audio input
  71. '                 device. Use this handle to identify the device when calling other
  72. '                 waveform-audio input functions. This parameter can be NULL if WAVE_FORMAT_QUERY
  73. '                 is specified for fdwOpen.
  74. '     uDeviceID-  a long value that identifies the waveform-audio input device to open.
  75. '                 This parameter can be either a device identifier or a handle of an open
  76. '                 waveform-audio input device.
  77. '     lpFormat-   the WAVEFORMAT user-defined typed that identifies the desired format for
  78. '                 recording waveform-audio data.
  79. '     dwCallback- a long value that is an event handle, a handle to a window, or the identifier
  80. '                 of a thread to be called during waveform-audio recording to process messages
  81. '                 related to the progress of recording. If no callback function is required,
  82. '                 this value can be zero. For more information on the callback function,
  83. '                 see waveInProc.
  84. '     dwCallback- a long value that is the user-instance data passed to the callback mechanism.
  85. '                 This parameter is not used with the window callback mechanism.
  86. '     dwFlags-    Flags for opening the device. The following values are defined:
  87. '                 CALLBACK_EVENT (&H50000)-event handle.
  88. '                 CALLBACK_FUNCTION (&H30000)-callback procedure address.
  89. '                 CALLBACK_NULL (&H00000)-No callback mechanism. This is the default setting.
  90. '                 CALLBACK_THREAD (&H20000)-thread identifier.
  91. '                 CALLBACK_WINDOW (&H10000)-window handle.
  92. '                 WAVE_FORMAT_DIRECT (&H8)-ACM driver does not perform conversions on the
  93. '                                            audio data.
  94. '                 WAVE_FORMAT_QUERY (&H1)-queries the device to determine whether it supports
  95. '                                         the given format, but it does not open the device.
  96. '                 WAVE_MAPPED (&H4)-The uDeviceID parameter specifies a waveform-audio device
  97. '                                   to be mapped to by the wave mapper.
  98.  
  99. Declare Function waveInPrepareHeader Lib "winmm.dll" (ByVal hWaveIn As Long, _
  100.                                                       lpWaveInHdr As WAVEHDR, _
  101.                                                       ByVal uSize As Long) As Long
  102. ' The waveInPrepareHeader function prepares a buffer for waveform-audio input. The function
  103. ' uses the following parameters:
  104. '     hWaveIn-    a long value that is the handle of the waveform-audio input device.
  105. '     lpWaveInHdr-the WAVEHDR user-defined type variable.
  106. '     uSize-      the size in bytes of the WAVEHDR user-defined type variable. Use the
  107. '                 results of the Len function for this parameter.
  108.  
  109.  
  110. Declare Function waveInReset Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
  111. ' The waveInReset function stops input on the given waveform-audio input device and resets
  112. ' the current position to zero. All pending buffers are marked as done and returned to
  113. ' the application. The function requires the handle to the waveform-audio input device.
  114.  
  115. Declare Function waveInStart Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
  116. ' The waveInStart function starts input on the given waveform-audio input device. The function
  117. ' requires the handle of the waveform-audio input device.
  118.  
  119. Declare Function waveInStop Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
  120. ' The waveInStop function stops waveform-audio input. The function requires the handle of
  121. ' the waveform-audio input device.
  122.  
  123. Declare Function waveInUnprepareHeader Lib "winmm.dll" _
  124.                                           (ByVal hWaveIn As Long, _
  125.